package com.liusj.controller;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.liusj.dao.model.City;
import com.liusj.dao.mapper.CityMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/4/19 0019.
 */
@RestController
@RequestMapping("/city")
public class CityController {
    @Autowired
    private CityMapper cityMapper;

    @RequestMapping("/get")
    public Object findByStateTest() {
        City city = cityMapper.findByState("浙江省");
        return city;
    }

    @RequestMapping("/all")
    public Object findAllCity() throws JsonProcessingException {
        List<Map<String,Object>> allCitys = cityMapper.getAllCitys();
        Object o = JSON.toJSON(allCitys);
        return o;
    }
}
